package com.ruoyi.system.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.OrderAuthenticationTimer;
import com.ruoyi.system.service.IOrderAuthenticationTimerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 订单实名认证定时器Controller
 *
 * @author hjf
 * @date 2025-05-19
 */
@RestController
@RequestMapping("/hmk/timer")
public class OrderAuthenticationTimerController extends BaseController {
    @Autowired
    private IOrderAuthenticationTimerService orderAuthenticationTimerService;

    /**
     * 查询订单实名认证定时器列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderAuthenticationTimer orderAuthenticationTimer) {
        startPage();
        List<OrderAuthenticationTimer> list = orderAuthenticationTimerService.selectOrderAuthenticationTimerList(orderAuthenticationTimer);
        return getDataTable(list);
    }

    /**
     * 导出订单实名认证定时器列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:export')")
    @Log(title = "订单实名认证定时器", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderAuthenticationTimer orderAuthenticationTimer) {
        List<OrderAuthenticationTimer> list = orderAuthenticationTimerService.selectOrderAuthenticationTimerList(orderAuthenticationTimer);
        ExcelUtil<OrderAuthenticationTimer> util = new ExcelUtil<OrderAuthenticationTimer>(OrderAuthenticationTimer.class);
        util.exportExcel(response, list, "订单实名认证定时器数据");
    }

    /**
     * 获取订单实名认证定时器详细信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(orderAuthenticationTimerService.selectOrderAuthenticationTimerById(id));
    }

    /**
     * 新增订单实名认证定时器
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:add')")
    @Log(title = "订单实名认证定时器", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderAuthenticationTimer orderAuthenticationTimer) {
        return toAjax(orderAuthenticationTimerService.insertOrderAuthenticationTimer(orderAuthenticationTimer));
    }

    /**
     * 修改订单实名认证定时器
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:edit')")
    @Log(title = "订单实名认证定时器", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderAuthenticationTimer orderAuthenticationTimer) {
        return toAjax(orderAuthenticationTimerService.updateOrderAuthenticationTimer(orderAuthenticationTimer));
    }

    /**
     * 删除订单实名认证定时器
     */
    @PreAuthorize("@ss.hasPermi('hmk:timer:remove')")
    @Log(title = "订单实名认证定时器", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(orderAuthenticationTimerService.deleteOrderAuthenticationTimerByIds(ids));
    }
}
